package com.soft.javase.day14;

import java.io.IOException;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/5/24
 */
public class BSServer {
    public static void main(String[] args) {
        try (
                ServerSocket ss = new ServerSocket(8888)
        ) {
            System.out.println("服务器启动！");
            while (true) {
                try (
                        Socket socket = ss.accept();
                        PrintStream ps = new PrintStream(socket.getOutputStream())
                ) {
                    ps.println("HTTP/1.1 200 OK");
                    ps.println("Content-Type: text/html; charset=utf-8");
                    ps.println();
                    ps.println("欢迎 IP 上线！");
                    ps.flush();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
